package models;

import views.PlayerFrame;

public class Player extends Character {
	
	private PlayerFrame playerframe;
	
	private int current_lvl;
	private long current_xp;
	private long next_lvl_xp;

	public Player(int str, int agi, int vit, int i, int dex, String name) {
		super(str, agi, vit, i, dex, name);
		this.current_lvl = 1;
		this.current_xp = 0;
		this.next_lvl_xp = getXpRoofForLvl(this.current_lvl);
		playerframe = new PlayerFrame(400,400,this);
	}
	
	public PlayerFrame getPlayerFrame() {
		return this.playerframe;
	}
	
	public void addExperience(long xp) {
		this.current_xp = this.current_xp + xp;
		while(this.current_xp >= this.next_lvl_xp) {
			levelUp();
		}
	}
	
	private void levelUp() {
		this.current_lvl++;
		this.next_lvl_xp = getXpRoofForLvl(this.current_lvl);
	}

	private long getXpRoofForLvl(int currentLvl) {
		return 64*currentLvl*currentLvl;
	}

	protected void update() {
		this.playerframe.update();
	}
	
}
